home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
macros
/
latex209
/
contrib
/
trees
/
pstrees
/
ansi.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-28
|
855b
|
64 lines
#include <strings.h>
/* this `type less' definition of max is doubtless dangerous,
but it *seems* to work */
extern void *malloc();
max(a, b)
{
if (a > b) return(a);
else return(b);
}
void reverse(s)
char s[];
{
int c, i, j;
for (i=0, j = strlen(s)-1; i<j; i++,j--) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
}
void itoa(n,s)
char s[];
int n;
{
int i, sign;
if ((sign = n) < 0) /* record sign */
n = -n; /* make n positive */
i = 0;
do { /* generate digits in reverse order */
s[i++] = n % 10 + ' 0'; /* get next digit */
} while ((n /= 10) > 0); /* delete it */
if (sign < 0)
s[i++] = '-';
s[i] = '\0';
reverse(s);
}
/*
#include <stdio.h>
main()
{
char s[5];
strcpy(s,"dog");
printf("%s\n",s);
reverse(s);
itoa(4,s);
printf("%s\n",s);
}
*/